<template>
  <div class="right-statistics">
    <!--  <div ref="mySwiper" class="warningbox swiper-container"> -->
    <!-- <div class="swiper-wrapper"> -->
    <vue3-seamless-scroll
      class="v-s-s"
      :list="warning"
      :step="0.2"
      :hover="true"
    >
      <div
        :class="['swiper-slide', 'content', `warning${w.warnLevel}`]"
        v-for="(w, k) in warning"
        :key="k"
      >
        <img
          :src="`/guotuicon/${w.warnLevel}_${w.eventTypeCode}.jpg`"
          class="guoiconImg"
          alt=""
          srcset=""
        />
        <p class="warningcont">{{ w.publishTime }}{{ w.headline }}</p>
      </div>
    </vue3-seamless-scroll>
    <!-- </div> -->
    <!-- </div> -->
  </div>
</template>

<script setup lang="ts">
import { Close } from '@element-plus/icons-vue'
import dayjs from 'dayjs'
/* import Swiper from 'swiper'
import 'swiper/css/swiper.css' */
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'
import apis from '../api/api'
import { useWarningStore } from '@/pages/warning/store/store'
const warning = ref([])
const bjTime = ref(dayjs().subtract(5, 'minute').format('YYYY-MM-DD HH:mm:00'))
const warningCount = reactive({})
const mySwiper = ref(null)
let warningtimer: NodeJS.Timeout | null = null
const getwarningData = () => {
  apis.getTodayList().then(res => {
    warning.value = res.data
  })
}
onMounted(() => {
  getwarningData()
  warningtimer = setInterval(() => {
    getwarningData()
  }, 60 * 1000 * 2)
})
onUpdated(() => {})

onUnmounted(() => {
  warningtimer && clearInterval(warningtimer)
})
</script>

<style scoped lang="scss">
.right-statistics {
  position: absolute;
  right: 273px;
  top: 28px;
  width: 354px;
  height: 120px;
  overflow: hidden;
  z-index: 1200000;
  /*  .swiper-wrapper {
    height: 100px;
  } */
  .content {
    padding: 20px 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    &.warningRed {
      background: url(@/assets/images/warning-redBg.png) no-repeat center 100%/100%;
    }
    &.warningYellow {
      background: url(@/assets/images/warning-yellowBg.png) no-repeat center
        100%/100%;
    }
    &.warningOrange {
      background: url(@/assets/images/warning-orangeBg.png) no-repeat center
        100%/100%;
    }
    &.warningBlue {
      background: url(@/assets/images/warning-blueBg.png) no-repeat center 100%/100%;
    }
    .guoiconImg {
      width: 60px;
      height: 50px;
    }
    .warningcont {
      font-size: 16px;
      color: #ffffff;
      margin-left: 10px;
      line-height: 28px;
    }
    .close {
      color: #fff;
      align-self: flex-start;
      cursor: pointer;
    }
    .el-empty {
      text-align: center;
      margin: auto;
      padding: 0;
      .el-empty__description {
        color: #333;
      }
    }
    .warn-count {
      width: calc(20% - 20px);
      margin: 0 10px;
      img {
        width: 100%;
        height: auto;
      }
      &.Blue {
        --el-color-danger: blue;
      }
      &.Red {
        --el-color-danger: red;
      }
      &.Yellow {
        --el-color-danger: yellow;
      }
      &.Orange {
        --el-color-danger: orange;
      }
    }
  }
}
</style>
